package com.zhz.audit;

import com.zhz.common.tool.excel.autoconfig.annotation.EnableExcel;
import com.zhz.common.tool.validator.EnableFormValidator;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 员工启动类
 *
 * @author zhouhengzhe
 * @version 1.0
 * @date 2023/5/29 14:21
 */
@Slf4j
@EnableFeignClients
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.zhz.**.dao")
@ComponentScan("com.zhz.*")
@EnableFormValidator
@EnableTransactionManagement
@EnableExcel
public class AuditApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(AuditApplication.class, args);
        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        String appName = environment.getProperty("spring.application.name");
        String port = environment.getProperty("server.port");
        String hostAddress = InetAddress.getLocalHost().getHostAddress();
        //启动完成后在控制台提示项目启动成功，并且输出当前服务对应的swagger接口文档访问地址
        //http://localhost:8080/doc.html
        log.info("应用{}启动成功!swagger地址：http://{}:{}/doc.html", appName, hostAddress, port);
        log.info("应用{}启动成功!druid地址：http://{}:{}/druid/index.html", appName, hostAddress, port);
    }
}
